#!/bin/bash

# 运行脚本

set -e

echo "Starting Blockchain API Service..."

# 检查配置文件
if [ ! -f "config.yaml" ]; then
    echo "Warning: config.yaml not found, using default configuration"
fi

# 创建数据目录
mkdir -p data

# 设置环境变量
export GIN_MODE=release
export LOG_LEVEL=info

# 运行应用
if [ -f "build/blockchain-api" ]; then
    echo "Running from build directory..."
    ./build/blockchain-api
elif [ -f "blockchain-api" ]; then
    echo "Running from current directory..."
    ./blockchain-api
else
    echo "Binary not found, building and running..."
    go run cmd/api/main.go
fi
